
public class StackNodo <Elem> {
	private Nodo first;
	private Nodo list;
	private int numero;
	private int maximo;
	
	public StackNodo(int Max){
		first = null;
		list = null;
		numero = 0;
		maximo = Max;
	}//end
	
	public void guardar(Elem obj)
	{
		Nodo ad = new Nodo();
		ad.setData(obj);
		if(first == null)
		{
			first = ad;
			list = first;
			numero++;
		}
		else
		{
			list.setNext(ad);
			list = list.getNext();
			numero++;
		}
	}//end
	
    public int sizeStack()
    {
    	return maximo;
    }
	
    public String showElements()
    {
    	String cad = "";
    	Nodo temp = first;
    	int i = 1;
    	while(temp != null)
    	{
    		cad += Integer.toString(i) +": Dato: "+temp.getData()+"\n";
    		temp = temp.getNext();
    		i++;
    	}//end
    	return cad;
    }//end
    
	public boolean Empty()
	{
		if(numero < maximo)
			return true;
		else
			return false;
	}//end
	
	public void Sacar(Elem obj)
	{
		Nodo temp = first;
		Nodo Ant = null;
		boolean cambiado = false;
		while((temp != null)&&(!cambiado))
		{
			if(numero >= 0)
			{
				if(temp.getData().equals(obj))
				{
					Ant.setNext(temp.getNext());
					cambiado = true;
					numero--;
					temp = temp.getNext();
				}//end
				else
				{
					Ant = temp;
					temp = temp.getNext();
				}//end
			}//end
			else
			{
				cambiado = true;
			}
		}//end
	}
}//end
